setwd(out_path)
if(!dir.exists("Outcomes")){
	dir.create("Outcomes")
}else{
	warning("Overwriting previous run, if any")
}
setwd("Outcomes")


#######
#Policy outcomes
#######

#Probit
base.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code +
 			  econ.policies + fp.policies, data=aic_clean, 
 			  family = binomial(link="probit")) 

ctls.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code + 
			econ.policies + fp.policies + 
			b.scaled.intgrp + m.scaled.intgrp, 
			data=aic_clean, family = binomial(link="probit")) 

full.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code + 
			econ.policies + fp.policies +
			b.scaled.intgrp + m.scaled.intgrp + 
			rep + dem, 
			data=aic_clean, family = binomial(link="probit")) 

#############
#Policy outcomes, by issue
#############

#Probit, FP
fp.base.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code,
			data=fp.policies, family = binomial(link="probit")) 

fp.ctls.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code +
			b.scaled.intgrp + m.scaled.intgrp,
			data=fp.policies, family = binomial(link="probit")) 

fp.full.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code + 
			b.scaled.intgrp + m.scaled.intgrp + 
			rep + dem, 
			data=fp.policies, family = binomial(link="probit")) 

#Probit, EC
ec.base.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code,
			data=econ.policies, family = binomial(link="probit")) 

ec.ctls.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code +
			b.scaled.intgrp + m.scaled.intgrp,
			data=econ.policies, family = binomial(link="probit")) 

ec.full.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code + 
			b.scaled.intgrp + m.scaled.intgrp + 
			rep + dem, 
			data=econ.policies, family = binomial(link="probit")) 

#Probit, NE
ne.base.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code,
			data=ne.policies, family = binomial(link="probit")) 

ne.ctls.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code +
			b.scaled.intgrp + m.scaled.intgrp,
			data=ne.policies, family = binomial(link="probit")) 

ne.full.mv.glm <- glm(bioutcome ~ pred50_sw + pred90_sw + rescaled_ideol_code + 
			b.scaled.intgrp + m.scaled.intgrp + 
			rep + dem, 
			data=ne.policies, family = binomial(link="probit")) 

############
#Tables
############

#Outcomes models, aggregate (probit model)
texreg(list(base.mv.glm, ctls.mv.glm, full.mv.glm),
	file="2_glm_OUT.tex",
	custom.coef.names = c("(intercept)","Middle Class Preferences", "Affluent Preferences", "Ideology" , 
		"Economic Policies" , "Foreign Policies", "Business Preferences" , "Advocacy Group Preferences" , 
		"Republican Support", "Democratic Support"),
	caption = "Probit Models of Policy Adoption",
	caption.above=T,
	custom.model.names = c(" Base ","Expanded", " Full "))

#Outcomes models, by issues, FP
texreg(list(fp.base.mv.glm, fp.ctls.mv.glm, fp.full.mv.glm),
	file="2_glm_OUTbyISS_FP.tex",
	custom.coef.names = c("(intercept)","Middle Class Preferences", "Affluent Preferences", "Ideology" , 
		"Business Preferences" , "Advocacy Group Preferences" , 
		"Republican Support", "Democratic Support"),
	caption = "Foreign Policy Outcomes vs. Preferences (Probit model)",
	caption.above=T,
	custom.model.names = c(" Base ","Expanded", " Full "))

#Outcomes models, by issues, EC
texreg(list(ec.base.mv.glm, ec.ctls.mv.glm, ec.full.mv.glm),
	file="2_glm_OUTbyISS_ECON.tex",
	custom.coef.names = c("(intercept)","Middle Class Preferences", "Affluent Preferences", "Ideology" , 
		"Business Preferences" , "Advocacy Group Preferences" , 
		"Republican Support", "Democratic Support"),
	caption = "Economic Policy Outcomes vs. Preferences (Probit model)",
	caption.above=T,
	custom.model.names = c(" Base ","Expanded", " Full "))

#Outcomes models, by issues, NE
texreg(list(ne.base.mv.glm, ne.ctls.mv.glm, ne.full.mv.glm),
	file="2_glm_OUTbyISS_NE.tex",
	custom.coef.names = c("(intercept)","Middle Class Preferences", "Affluent Preferences", "Ideology" , 
		"Business Preferences" , "Advocacy Group Preferences" , 
		"Republican Support", "Democratic Support"),
	caption = "Social Policy Outcomes vs. Preferences (Probit model)",
	caption.above=T,
	custom.model.names = c(" Base ","Expanded", " Full "))


#Outcomes models, by issues, All Issues
texreg(list(fp.base.mv.glm, fp.ctls.mv.glm, fp.full.mv.glm, ec.base.mv.glm, ec.ctls.mv.glm, ec.full.mv.glm, ne.base.mv.glm, ne.ctls.mv.glm, ne.full.mv.glm),
	file="2_glm_OUTbyISS_All.tex",
	custom.coef.names = c("(intercept)","Middle Class Preferences", "Affluent Preferences", "Ideology" , 
		"Business Preferences" , "Advocacy Group Preferences" , 
		"Republican Support", "Democratic Support"),
	caption = "Probit Models of Policy Adoption by Issue Area",
	caption.above=T,
	custom.model.names = c("Foreign","Foreign", "Foreign","Econ","Econ", "Econ","Social","Social", "Social"))

setwd(script_path)